package com.knight.study.patterns.tujie.observer;

import java.util.ArrayList;
import java.util.Iterator;

/**
 * @Author knight
 * @Date 2024/9/12 11:32
 */

public abstract class NumberGenerator {
    private ArrayList observers = new ArrayList();
    public void addObserver(Observer observer) {
        observers.add(observer);
    }
    public void deleteObserver(Observer observer) {
        observers.remove(observer);
    }
    public void notifyObservers(){
        final Iterator it = observers.iterator();
        while (it.hasNext()) {
            Observer o = (Observer) it.next();
            o.update(this);
        }
    }
    public abstract int getNumber();
    public abstract void execute();
}
